$(function(){
	const money = $('#money'),
		detail = $('#detail'),
        time = $('#time'),
        account = $('#account');


	function GetQueryString (name) { //获取指定name的url参数
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return (r[2]);
        return null;
    }
    function Toast (txt){
        var toastHtml = '<div class="tk_info" id="tkInfo"></div>';
        var toast = $('body #tkInfo');
        if (toast.length) {
            toast.html(txt).show();
        }else{
            $('body').append(toastHtml);
            $('body #tkInfo').html(txt).show();
        }
        setTimeout(function(){
          $('body #tkInfo').hide();
        },3000)
    }

    const id = GetQueryString('id')||'2849740';
    const userId = GetQueryString('userId')||'9381331';
    const token = GetQueryString('token')||'8c6429d4292647a8b7d7d3c457bb4647';
    const key = 'http://video.shnongc.cn';
   
    detail.attr('href','withdraw-detail.html?id='+id+'&userId='+userId+'&token='+token)
    function getUserInfo(){
        $.ajax({
            type:'get',
            dataType: 'json',
            url:key+'/system/api/transfer/transferStatus',
            data: {
                'userId':userId,
                'token':token,
                'id':id
            },
            //请求成功时执行
            success: function(v) {
                const code = v.code;
                const msg = v.msg;
                const data = v.data;
                if (code == 0) {
                    money.html(data.txMoney)
                   time.html(data.createTime)
                   account.html(data.wechatName)
                } else {
                    // 异常处理
                   Toast(msg)
                }
            },
            //请求失败遇到异常触发
            error: function(d) {
                console.log(d.msg);
                window.webkit.messageHandlers.MJLogin.postMessage(null)
            }
        })
    }
    getUserInfo()
})